package ma.ensao.evalmetrics.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import org.apache.log4j.chainsaw.Main;

import ma.ensao.evalmetrics.controller.metrics.Calcule;
import ma.ensao.evalmetrics.model.Caracteristiques;
import ma.ensao.evalmetrics.model.Metriques;
import ma.ensao.evalmetrics.model.Propriete;
import ma.ensao.evalmetrics.model.Result;
import ma.ensao.evalmetrics.model.ResultMethod;
import ma.ensao.evalmetrics.model.Subcarac;

import com.opensymphony.xwork2.ActionSupport;

public class Caract_table extends ActionSupport {

	private Long id;
	private List<Caracteristiques> list ;

	public List<Caracteristiques> getList() {
		return list;
	}
	public void setList(List<Caracteristiques> list) {
		this.list = list;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	private Metriques parametres;
	private Caracteristiques carac;
	private Subcarac sub;
	private Result result;
	private Propriete propriete;
	private Calcule calcule = new Calcule();
	private MetriquesManager metriquesmanager = new MetriquesManager();
	private ProprieteManager proprietemanager = new ProprieteManager();
	private CaracteristiquesManager caracteristiques = new CaracteristiquesManager();
	private SubcaracManager subcarac = new SubcaracManager();

	private ResultManager resultmanager = new ResultManager();

public String caracteristiques() {
	
	
	List<Result> liste = resultmanager.MesResultat(id);
	list = new ArrayList<Caracteristiques>();

		for (int i = 1; i <= liste.size(); i++) {
			result = liste.get(i - 1);
			

			parametres = metriquesmanager.list(id).get(0);
			parametres = calcule.calculMetrique(parametres, result);
			propriete = proprietemanager.list(id).get(0);
			propriete = calcule.calculPropriete(propriete);
			sub = subcarac.list(id).get(0);
			sub = calcule.calculSubcarac(sub);
			carac = caracteristiques.list(id).get(0);
			carac = calcule.calculCaracteristiques(carac);
			carac.setId(result.getId());

			list.add(carac);
			System.out.println("efiiicactit"+carac.getEfficacite());
		
		}
		return SUCCESS;
	}

	public static void main(String[] args) throws IOException, ClassNotFoundException {

		Caract_table c = new Caract_table();
		c.setId(38L);
		c.caracteristiques();
		List<Caracteristiques> list = c.getList();
		int i=0;
		for(Caracteristiques res : list){
			i++;
		}
		System.out.println("ffffffff"+i);
		
		
		
		 
	}
	
}